package com.zhisheng.advice;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

/**
 * 创建者： 智晟全哥
 *
 * 这个类承载着我们如何对已有的业务功能进行增强的逻辑
 *
 *
 */

@Component
@Aspect
public class MyAspect {

    @Around("execution(* com.zhisheng.service.impl.*.*(..))")
    public Object totalTime(ProceedingJoinPoint pjp) throws Throwable {
        // 开始写增强的逻辑
        long t1 = System.currentTimeMillis();
        // 让原始方法执行
        Object o = pjp.proceed();
        long t2 = System.currentTimeMillis();
        long l = t2 - t1;
        System.out.println(pjp.getSignature().getDeclaringTypeName()+"类中的"+pjp.getSignature().getName()+"方法执行耗时:"+l+" 毫秒-----------------------------------------------------------");
        return o;

    }
}
